import axios from "axios"
let cheyi = {
    state: {
        token: "",
    },
    getters: {
    },
    mutations: {
        // 修改token，并将token存入localStorage
        SET_TOKEN(state, payload) {
            state.token = payload.key;
            localStorage.setItem('token', token);
            console.log('store、localstorage保存token成功！');
        },
        delToken(state) {
            state.token = "";
            localStorage.removeItem("token");
        },
        setToken(state, payload) {
            state.token = payload.data
        }
    },

    actions: {
        removeToken: (context) => {
            axios({
                url: "/user/isAuthenticated",
                method: "get",
            }).then((ok) => {
                console.log(ok.data)
                context.commit('setToken', { data: ok.data.data })

            })
        }
    },

}
export default cheyi
